package com.sailfish.springbootdemo.controller.db2;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.PutObjectResult;
import com.sailfish.springbootdemo.configs.UserHeaderHolder;
import com.sailfish.springbootdemo.dao.db2.AxiConfigDao;
import com.sailfish.springbootdemo.pojo.Result;
import com.sailfish.springbootdemo.service.db2.S3UploadFileService;
import com.sailfish.springbootdemo.service.db5.SfcScdpMSnDetailService;
import com.sailfish.springbootdemo.utils.CommonUtils;
import com.sailfish.springbootdemo.utils.HttpUtil;
import com.sailfish.springbootdemo.utils.ResultUtil;
import com.sailfish.springbootdemo.utils.SfsUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.util.*;
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/Axi")
public class AxiController {

    @Value("${personal.config.apis.sign}")
    private String sign;
    @Value("${third_url_prefix.axi-url}")
    private String getAxiApi;
    @Autowired
    private AmazonS3 amazonS3;

    @Value("${personal.config.amazon-s3.url}")
    private String url;
    @Value("${personal.config.amazon-s3.file-bucket}")
    private String fileBucket;
    @Autowired
    SfsUtils sfsUtils;
    @Autowired
    AxiConfigDao axiConfigDao;
    @Autowired
    S3UploadFileService s3UploadFileService;
    @Autowired
    SfcScdpMSnDetailService sfcScdpMSnDetailService;
    @Value("${personal.config.file.file-save-url}")
    private String fileSaveUrl;
    @PostMapping("/refreshAxiDataInfo")
    public Result refreshAxiData() {
        String refreshAxiDataApi = getAxiApi + "/api/Axi/refreshAxiDataInfo";
        try {
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("userId", userId);
            params.put("projectId", "");

            String res = HttpUtil.sendPostJson(refreshAxiDataApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("refreshAxiDataApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if (resObj.get("Code") != null) {
                if ("200".equals(resObj.get("Code").toString())) {
                    return ResultUtil.success(null);
                }
                return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
            }
            return ResultUtil.error(500, "请求失败接口地址：" + refreshAxiDataApi, "Request Fail", null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + refreshAxiDataApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/getAxiData")
    public Result getAxiData(String type, String search, Integer page, Integer pageSize) {
        String getAxiDataApi = getAxiApi + "/api/Axi/getAxiData";
        System.out.println("getAxiDataApi:" + getAxiDataApi);
        try {
            if (type == null || "".equals(type)) {
                return ResultUtil.error(500, "缺少参数type", "Miss Param type", null);
            }
            if (page == null || "".equals(page.toString())) {
                return ResultUtil.error(500, "缺少参数page", "Miss Param page", null);
            }
            if (pageSize == null || "".equals(pageSize.toString())) {
                return ResultUtil.error(500, "缺少参数pageSize", "Miss Param pageSize", null);
            }
            if (!CommonUtils.isNumeric(page.toString()) || !CommonUtils.isNumeric(pageSize.toString())) {
                return ResultUtil.error(500, "错误参数page或者pageSize", "Error Param page or pageSize", null);
            }
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("type", type);
            params.put("search", search);
            params.put("page", page);
            params.put("pageSize", pageSize);
            params.put("userId", userId);
            String res = HttpUtil.sendPostJson(getAxiDataApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("getAxiDataApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
                System.out.println(resObj.get("Data").toString());
                JSONObject d = resObj.getJSONObject("Data");
                Integer totalCount = d.getInteger("totalCount");
                JSONArray ja = d.getJSONArray("data");
                return ResultUtil.tableSuccess(page, pageSize, totalCount, ja);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getAxiDataApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/outputAxi")
    public Result outputAxi(String type, String search) {
        String outputAxiApi = getAxiApi + "/api/Axi/outputAxi";
        try {
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("type", type);
            params.put("search", search);
            String res = HttpUtil.sendPostJson(outputAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("outputAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(resObj.get("Data"));
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + outputAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/outputAxiSelect")
    public Result outputAxiSelect(String ids) {
        String outputAxiApi = getAxiApi + "/api/Axi/outputAxiSelect";
        try {
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("ids", ids);
            String res = HttpUtil.sendPostJson(outputAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("outputAxiSelect:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(resObj.get("Data"));
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + outputAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/update")
    public Result updateAxi(Integer id, String test_rate, String test_project, String remark, String table_type) {
        String updateAxiApi = getAxiApi + "/api/Axi/update";
        try {
            if (id == null || "".equals(id.toString())) {
                return ResultUtil.error(500, "缺少参数id", "Miss Param id", null);
            }

            String userId = UserHeaderHolder.getUserId();
            String userName = UserHeaderHolder.getDomainAccount();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("id", id);
            params.put("userName", userName);
            params.put("test_rate", test_rate);
            params.put("test_project", test_project);
            params.put("remark", remark);
            params.put("table_type", table_type);
            params.put("userId", userId);
            String res = HttpUtil.sendPostJson(updateAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("updateAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + updateAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/delete")
    public Result deleteAxi(String ids) {
        String deleteAxiApi = getAxiApi + "/api/Axi/delete";
        try {
            if (ids == null || "".equals(ids)) {
                return ResultUtil.error(500, "缺少参数ids", "Miss Param ids", null);
            }
            String userId = UserHeaderHolder.getUserId();
            String userName = UserHeaderHolder.getDomainAccount();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("ids", ids);
            params.put("userId", userId);
            params.put("userName", userName);
            String res = HttpUtil.sendPostJson(deleteAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("deleteAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + deleteAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/updateConfig")
    public Result updateConfig(@RequestBody String data) {

        String updateConfigAxiApi = getAxiApi + "/api/Axi/updateConfig";
        try {
            JSONObject jsonObject = JSONObject.parseObject(data);
            Integer id = jsonObject.getInteger("id");
            String attr_value = jsonObject.getString("attr_value");
            String attr_desc = jsonObject.getString("attr_desc");
            String remark = jsonObject.getString("remark");
            if (id == null) {
                return ResultUtil.error(500, "缺少参数id", "Miss Param id", null);
            }
            String userId = UserHeaderHolder.getUserId();
            String userName = UserHeaderHolder.getDomainAccount();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("id", id);
            params.put("userId", userId);
            params.put("attr_value", attr_value);
            params.put("attr_desc", attr_desc);
            params.put("remark", remark);
            String res = HttpUtil.sendPostJson(updateConfigAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("updateConfigAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + updateConfigAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/getAxiConfigList")
    public Result getAxiConfigList() {
        String getAxiConfigListAxiApi = getAxiApi + "/api/Axi/getAxiConfigList";
        try {
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            String res = HttpUtil.sendPostJson(getAxiConfigListAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("deleteAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                final JSONArray data = resObj.getJSONArray("Data");
                return ResultUtil.success(data);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getAxiConfigListAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/getApproveConfigList")
    public Result getApproveConfigList(String str_search) {
        String getApproveConfigListAxiApi = getAxiApi + "/api/Axi/getApproveConfigList";
        try {
            if (str_search == null) {
                return ResultUtil.error(500, "缺少参数str_search", "Miss Param str_search", null);
            }
            String userId = UserHeaderHolder.getUserId();
            String userName = UserHeaderHolder.getDomainAccount();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("str_search", str_search);
            params.put("userId", userId);
            params.put("userName", userName);
            String res = HttpUtil.sendPostJson(getApproveConfigListAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("getApproveConfigListAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                System.out.println(resObj.get("Data").toString());
                JSONArray d = resObj.getJSONArray("Data");
                return ResultUtil.success(d);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getApproveConfigListAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/updateApproveConfig")
    public Result updateApproveConfig(@RequestBody String data) {
        String updateApproveConfigListAxiApi = getAxiApi + "/api/Axi/updateApproveConfig";
        try {
            JSONObject jsonObject = JSONObject.parseObject(data);
            Integer id = jsonObject.getInteger("id");
            String product_line = jsonObject.getString("product_line");
            String product_name = jsonObject.getString("product_name");
            JSONArray approve_users = jsonObject.getJSONArray("approve_users");
            if (id == null) {
                return ResultUtil.error(500, "缺少参数id", "Miss Param id", null);
            }
            String userId = UserHeaderHolder.getUserId();
            String userName = UserHeaderHolder.getDomainAccount();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("approve_users", approve_users);
            params.put("id", id);
            params.put("product_line", product_line);
            params.put("product_name", product_name);
            String res = HttpUtil.sendPostJson(updateApproveConfigListAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("updateApproveConfigListAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + updateApproveConfigListAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/deleteApproveConfig")
    public Result deleteApproveConfig(Integer id) {
        String deleteApproveConfigAxiApi = getAxiApi + "/api/Axi/deleteApproveConfig";
        try {
            if (id == null) {
                return ResultUtil.error(500, "缺少参数id", "Miss Param id", null);
            }
            String userId = UserHeaderHolder.getUserId();
            String userName = UserHeaderHolder.getDomainAccount();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("id", id);
            params.put("userId", userId);
            params.put("userName", userName);
            String res = HttpUtil.sendPostJson(deleteApproveConfigAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("deleteApproveConfigAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + deleteApproveConfigAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/addApproveConfig")
    public Result addApproveConfig(@RequestBody String data) {
        String addApproveConfigAxiApi = getAxiApi + "/api/Axi/addApproveConfig";
        try {
            JSONObject jsonObject = JSONObject.parseObject(data);
            String product_line = jsonObject.getString("product_line");
            String product_name = jsonObject.getString("product_name");
            JSONArray approve_users = jsonObject.getJSONArray("approve_users");

            String userId = UserHeaderHolder.getUserId();
            String userName = UserHeaderHolder.getDomainAccount();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("approve_users", approve_users);
            params.put("product_line", product_line);
            params.put("product_name", product_name);
            String res = HttpUtil.sendPostJson(addApproveConfigAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("addApproveConfigAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + addApproveConfigAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/getApproveDataList")
    public Result getApproveDataList(String type, String str_search, Integer page, Integer pageSize) {
        String getApproveDataListAxiApi = getAxiApi + "/api/Axi/getApproveDataList";
        try {
            if (page == null || "".equals(page.toString())) {
                return ResultUtil.error(500, "缺少参数page", "Miss Param page", null);
            }
            if (pageSize == null || "".equals(pageSize.toString())) {
                return ResultUtil.error(500, "缺少参数pageSize", "Miss Param pageSize", null);
            }
            if (!CommonUtils.isNumeric(page.toString()) || !CommonUtils.isNumeric(pageSize.toString())) {
                return ResultUtil.error(500, "错误参数page或者pageSize", "Error Param page or pageSize", null);
            }
            String userId = UserHeaderHolder.getUserId();
            String userName = UserHeaderHolder.getDomainAccount();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("type", type);
            params.put("str_search", str_search);
            params.put("userId", userId);
            params.put("page", page);
            params.put("pageSize", pageSize);
            String res = HttpUtil.sendPostJson(getApproveDataListAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("getApproveDataListAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                System.out.println(resObj.get("Data").toString());
                JSONObject d = resObj.getJSONObject("Data");
                Integer totalCount = d.getInteger("totalCount");
                JSONArray ja = d.getJSONArray("data");
                return ResultUtil.tableSuccess(page, pageSize, totalCount, ja);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getApproveDataListAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/getApproveRecordList")
    public Result getApproveRecordList(String type, String str_search, Integer page, Integer pageSize) {
        String getApproveRecordListAxiApi = getAxiApi + "/api/Axi/getApproveRecordList";
        try {
            if (page == null || "".equals(page.toString())) {
                return ResultUtil.error(500, "缺少参数page", "Miss Param page", null);
            }
            if (pageSize == null || "".equals(pageSize.toString())) {
                return ResultUtil.error(500, "缺少参数pageSize", "Miss Param pageSize", null);
            }
            if (!CommonUtils.isNumeric(page.toString()) || !CommonUtils.isNumeric(pageSize.toString())) {
                return ResultUtil.error(500, "错误参数page或者pageSize", "Error Param page or pageSize", null);
            }
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("type", type);
            params.put("str_search", str_search);
            params.put("userId", userId);
            params.put("page", page);
            params.put("pageSize", pageSize);
            String res = HttpUtil.sendPostJson(getApproveRecordListAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("getApproveRecordListAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                System.out.println(resObj.get("Data").toString());
                JSONObject d = resObj.getJSONObject("Data");
                Integer totalCount = d.getInteger("totalCount");
                JSONArray ja = d.getJSONArray("data");
                return ResultUtil.tableSuccess(page, pageSize, totalCount, ja);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getApproveRecordListAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/approveCacheAxiData")
    public Result approveCacheAxiData(@RequestBody String data) {
        String approveCacheAxiDataAxiApi = getAxiApi + "/api/Axi/approveCacheAxiData";
        try {
            JSONObject jsonObject = JSONObject.parseObject(data);
            final JSONObject userInfo = jsonObject.getJSONObject("userInfo");
            final JSONArray list = jsonObject.getJSONArray("list");
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("userId", userId);
            params.put("list", list);
            String res = HttpUtil.sendPostJson(approveCacheAxiDataAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("approveCacheAxiDataAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + approveCacheAxiDataAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/rejectCacheAxiData")
    public Result rejectCacheAxiData(@RequestBody String data) {
        String rejectCacheAxiDataAxiApi = getAxiApi + "/api/Axi/rejectCacheAxiData";
        try {
            JSONObject jsonObject = JSONObject.parseObject(data);
            final JSONObject userInfo = jsonObject.getJSONObject("userInfo");
            final JSONArray list = jsonObject.getJSONArray("list");
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("userId", userId);
            params.put("list", list);
            String res = HttpUtil.sendPostJson(rejectCacheAxiDataAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("rejectCacheAxiDataAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + rejectCacheAxiDataAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/updateAxiRule")//HttpServletRequest req,String ruleContent,Integer attachment
    public Result updateAxiRule( @RequestBody String data) {
        String updateAxiRuleAxiApi = getAxiApi + "/api/Axi/updateAxiRule";
        try {
            final JSONObject jsonObject = JSONObject.parseObject(data);
            String ruleContent = jsonObject.getString("ruleContent");
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("ruleContent", ruleContent);
            params.put("userId", userId);

            String res = HttpUtil.sendPostJson(updateAxiRuleAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("updateAxiRuleAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + updateAxiRuleAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }
    @PostMapping("/uploadFile")
    public Result uploadFile( HttpServletRequest req) {
        String originalName = "";
        try {
            Map<String, String> map = new HashMap<>();
            MultipartHttpServletRequest mRequest = (MultipartHttpServletRequest) req;
            MultipartFile multipartFile = mRequest.getFile("file");

            originalName = multipartFile.getOriginalFilename();
            String newName = originalName + "-" + UUID.randomUUID().toString() +
                    originalName.substring(originalName.lastIndexOf("."), originalName.length());
            String directory = "capacityFiles/uploadFile";

                //将MultipartFile转成File
                File file = File.createTempFile("temp", ".temp");
                InputStream inputStream = multipartFile.getInputStream();
                OutputStream os = new FileOutputStream(file);
                int bytesRead = 0;
                byte[] buffer = new byte[1024];
                while ((bytesRead = inputStream.read(buffer)) != -1) {
                    os.write(buffer, 0, bytesRead);
                }
                os.close();
                inputStream.close();
                System.out.println("将MultipartFile转成File成功");

                ObjectMetadata metadata = new ObjectMetadata();
                metadata.setContentType("application/octet-stream");
                PutObjectResult result = amazonS3.putObject(new PutObjectRequest(fileBucket,
                        directory + "/" + newName, new FileInputStream(file), metadata)
                        //配置访问权限
                        .withCannedAcl(CannedAccessControlList.PublicRead));
                System.out.println("upload file to amazon s3 result is " + result.getContentMd5());
                String address = directory + "/" + newName;

                String httpUrl = url + "/" + fileBucket + "/" + address;

                map.put("axi_attachment", newName);
                map.put("oldName", originalName);
                map.put("address", address);
                map.put("httpUrl", httpUrl);

                return ResultUtil.success(map);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(String.format("上传文件【%s】到AmazonS3失败:", originalName) + e.getMessage());
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
//        try {
//            MultipartHttpServletRequest mRequest = (MultipartHttpServletRequest) req;
//            MultipartFile file = mRequest.getFile("file");
//            if(Objects.isNull(file) || file.isEmpty())
//            {
//                log.error("null file");
//                return ResultUtil.error(500, "文件为空", "null file", null);
//            }
//            if (!StringUtils.isBlank(env)) {
//                Map<String, String> map = new HashMap<>();
//                String oldName = file.getOriginalFilename();
//                log.info("file name:" + oldName);
//                if (env.equals("dev")) {
//                    //获取项目目录
//                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//                    String format = sdf.format(new Date());
//                    File folder = new File(fileSaveUrl + "axiAttachments\\" + format);
//
//                    String filePath = "";
//                    if (!folder.isDirectory()) {
//                        folder.mkdirs();
//                    }
//
//                    String newName = UUID.randomUUID() +
//                            oldName.substring(oldName.lastIndexOf("."), oldName.length());
//
//                    file.transferTo(new File(folder, newName));
//                    filePath = "axiAttachments\\" + format + "\\" + newName;
//                    map.put("name", newName);
//                    map.put("oldName", oldName);
//                    map.put("relatePath", filePath);
//                    return ResultUtil.success(map);
//                } else {
//                    String secretKey = String.valueOf(UUID.randomUUID()).substring(0, 30);
//                    SfsUtils.SfsFileData data = sfsUtils.upload(file, secretKey);
//                    if (data == null) {
//                        log.error("上传接口返回data为空");
//                        return ResultUtil.error(500, "上传接口返回data为空", null, null);
//                    } else {
//                        String fileSid = data.getFileSid();
//                        log.info("fileSid field is " + fileSid);
//                        if (StringUtils.isBlank(fileSid)) {
//                            return ResultUtil.error(500, "上传接口返回data.fileSid为空", null, null);
//                        }
//                        map.put("oldName", oldName);
//                        map.put("secretKey", secretKey);
//                        map.put("fileSid", fileSid);
//                        return ResultUtil.success(map);
//                    }
//                }
//            } else {
//                return ResultUtil.error(500, "配置文件yml中未定义参数：env", "", null);
//            }
//        } catch (Exception e) {
//            log.error(e.getStackTrace().toString());
//            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
//        }
    }

    @PostMapping("/uploadHistoryList")
    public Result uploadHistoryList( HttpServletRequest req) {
        String uploadHistoryListAxiApi = getAxiApi + "/api/Axi/uploadHistoryList";
        try {
            MultipartHttpServletRequest mRequest = (MultipartHttpServletRequest) req;
            String base64 = null;
            String name = null;
            MultipartFile axi_attachment = mRequest.getFile("Axi_Attachment");
            if(axi_attachment != null){
                name = axi_attachment.getOriginalFilename();
                byte[] bytedata = null;
                InputStream in = axi_attachment.getInputStream();
                bytedata = new byte[in.available()];
                in.read(bytedata);
                in.close();
                Base64.Encoder encoder = Base64.getEncoder();
                base64 = encoder.encodeToString(bytedata);
            }

            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("axi_attachment", base64);
            params.put("filename", name);
            params.put("userId", userId);

            String res = HttpUtil.sendPostJson(uploadHistoryListAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("uploadHistoryListAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + uploadHistoryListAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }
    @PostMapping("/downloadS3File")
    public Result downloadSeFile(@RequestBody String requestBody)
    {
        JSONObject jsonObject = JSONObject.parseObject(requestBody);
        String url = jsonObject.getString("attr_value");
        String fileName = jsonObject.getString("remark");
        return s3UploadFileService.downloadS3FileToBase64(url, fileName);
    }
    @PostMapping("/uploadAllHistory")
    public Result uploadAllHistory(@RequestBody String requestBody) {
        try {
            // 将请求体字符串转换为 JSONObject
            JSONObject jsonObject = JSONObject.parseObject(requestBody);

            // 从请求体中获取 Axi_Attachment 参数
            JSONArray jsonArray = jsonObject.getJSONArray("Axi_Attachment");

            if (jsonArray == null || jsonArray.isEmpty()) {
                return ResultUtil.error(500, "没有文件被上传", "no file found uploaded", null);
            }

            // 准备参数列表
            ArrayList<JSONObject> filesList = new ArrayList<>();
            log.info("fileList size is " + jsonArray.size());
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject attachment = jsonArray.getJSONObject(i);
                String oldName = attachment.getString("oldName");
                String httpUrl = attachment.getString("httpUrl");

                // 获取用户ID
                String userId = UserHeaderHolder.getUserId();

                // 构建请求参数
                JSONObject params = new JSONObject();
                params.put("sign", ""); // sign 不再需要，直接置空
                params.put("axi_attachment", httpUrl); // 拼接后的字符串作为 axi_attachment 的值
                params.put("filename", oldName); // 放入文件名
                params.put("userId", userId);

                filesList.add(params);
            }

            // 检查是否有文件被上传
            if (filesList.isEmpty()) {
                return ResultUtil.error(500, "没有文件被上传", "no file found uploaded", null);
            }

            // 构建最终请求体
            JSONObject requestParams = new JSONObject();
            requestParams.put("files", filesList); // 将文件列表放入请求体

            // 调用外部API
            Integer rows = axiConfigDao.deleteByAttrName("Axi_Attachment");
            log.info("delete from tb_axi_config affected rows " + rows);
            String postUrl = getAxiApi + "/api/Axi/uploadAllHistory";
            String res = HttpUtil.sendPostJson(postUrl, requestParams);
            log.info(CommonUtils.formatCurrentTime() + "==========================================");
            log.info("uploadAllHistory API Response: " + res);

            // 解析返回值
            JSONObject resObj = JSONObject.parseObject(res);
            int code = resObj.getInteger("Code");
            String msg = resObj.getString("Msg");

            // 根据C#服务返回的结果构建相应的响应
            if (code != 200) {
                log.error("C#服务返回的结果msg:" + msg);
                return ResultUtil.error(code, msg, msg, null);
            } else {
                return ResultUtil.success("所有文件上传成功");
            }
        } catch (Exception e) {
            log.error(e.getStackTrace().toString());
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/downloadH3CFile")
    public Result downloadH3CFile(Integer fileId) {
        try {
            if (fileId == null) {
                return ResultUtil.error(500, "参数fileId为空", "param fileId is null", null);
            }
            JSONObject requestParams = new JSONObject();
            requestParams.put("id", fileId); // 将文件列表放入请求体

            // 调用外部API
            String getAxiConfigByIdApi = getAxiApi + "/api/Axi/getAxiConfigByIdApi";
            String res = HttpUtil.sendPostJson(getAxiConfigByIdApi, requestParams);
            //解析返回值
            JSONObject resObj = JSONObject.parseObject(res);
            int code = resObj.getInteger("Code");
            String msg = resObj.getString("Msg");
            JSONObject attachmentObj = resObj.getJSONObject("Data");
            if (code != 200) {
                log.error("Axi/downloadH3CFile err msg :" + msg);
                return ResultUtil.error(code, msg, msg, null);
            }
            String attr_value = attachmentObj.getString("attr_value");
            if(StringUtils.isBlank(attr_value))
            {
                return ResultUtil.error(code, "文件识别信息为空", "null mark infromation of current file", null);
            }
            String httpUrl = attachmentObj.getString("attr_value");
            String fileName = attachmentObj.getString("remark");
            Map<String, Object> map = new HashMap<>();
            map.put("httpUrl", httpUrl);
            map.put("fileName", fileName);
            return ResultUtil.success(map);
        } catch (Exception e) {
            log.error(e.getStackTrace().toString());
            return ResultUtil.error(500, "downloadH3CFile Exception:" + e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/getAxiRule")
    public Result getAxiRule() {
        String getAxiRuleAxiApi = getAxiApi + "/api/Axi/getAxiRule";
        try {
            String userId = UserHeaderHolder.getUserId();
            String userName = UserHeaderHolder.getDomainAccount();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            String res = HttpUtil.sendPostJson(getAxiRuleAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("getAxiRuleAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(resObj.get("Data"));
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getAxiRuleAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/getAxiOperation")
    public Result getAxiOperation(String code, String nickNameCn, String operateDataType, Integer page, Integer pageSize) {
        String getAxiOperationAxiApi = getAxiApi + "/api/Axi/getAxiOperation";
        try {
            if (page == null || "".equals(page.toString())) {
                return ResultUtil.error(500, "缺少参数page", "Miss Param page", null);
            }
            if (pageSize == null || "".equals(pageSize.toString())) {
                return ResultUtil.error(500, "缺少参数pageSize", "Miss Param pageSize", null);
            }
            if (!CommonUtils.isNumeric(page.toString()) || !CommonUtils.isNumeric(pageSize.toString())) {
                return ResultUtil.error(500, "错误参数page或者pageSize", "Error Param page or pageSize", null);
            }
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("code", code);
            params.put("nickNameCn", nickNameCn);
            params.put("operateDataType", operateDataType);
            params.put("userId", userId);
            params.put("page", page);
            params.put("pageSize", pageSize);
            String res = HttpUtil.sendPostJson(getAxiOperationAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("getAxiOperationAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                System.out.println(resObj.get("Data").toString());
                JSONObject d = resObj.getJSONObject("Data");
                Integer totalCount = d.getInteger("totalCount");
                JSONArray ja = d.getJSONArray("data");
                return ResultUtil.tableSuccess(page, pageSize, totalCount, ja);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getAxiOperationAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/getProductLines")
    public Result getProductLines() {
        String getProductLinesAxiApi = getAxiApi + "/api/Axi/getProductLines";
        try {
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            String res = HttpUtil.sendPostJson(getProductLinesAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("getProductLinesAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                final JSONArray data = resObj.getJSONArray("Data");
                return ResultUtil.success(data);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getProductLinesAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/getProductsByLine")
    public Result getProductsByLine(String productLine) {
        String getProductsByLineAxiApi = getAxiApi + "/api/Axi/getProductsByLine";
        try {
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("productLine", productLine);
            String res = HttpUtil.sendPostJson(getProductsByLineAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("getProductsByLineAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                final JSONArray data = resObj.getJSONArray("Data");
                return ResultUtil.success(data);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getProductsByLineAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/ChangeApprover")
    public Result ChangeApprover(@RequestBody String data) {
        String changeApproverAxiApi = getAxiApi + "/api/Axi/ChangeApprover";
        try {
            JSONObject jsonObject = JSONObject.parseObject(data);
            final JSONObject userInfo = jsonObject.getJSONObject("userInfo");
            final JSONArray list = jsonObject.getJSONArray("list");
            Integer approver = jsonObject.getInteger("approver");
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("userId", userId);
            params.put("approver", approver);
            params.put("list", list);
            String res = HttpUtil.sendPostJson(changeApproverAxiApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("changeApproverAxiApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + changeApproverAxiApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/getModifiedAxiData")
    public Result getModifiedAxiData(String search) {
        String getModifiedAxiDataApi = getAxiApi + "/api/Axi/getModifiedAxiData";
        try {
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
//            params.put("type", type);
            params.put("search", search);
//            params.put("page", page);
//            params.put("pageSize", pageSize);
            params.put("userId", userId);
            String res = HttpUtil.sendPostJson(getModifiedAxiDataApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("getModifiedAxiData:return " + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                final JSONArray data = resObj.getJSONArray("Data");
                return ResultUtil.success(data);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getModifiedAxiDataApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/cancelLimit")
    public Result cancelLimit(String ids) {
        String getAxiCancelLimitApi = getAxiApi + "/api/Axi/CancelLimit";
        try {
            String userId = UserHeaderHolder.getUserId();
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("ids", ids);
            params.put("userId", userId);
            String res = HttpUtil.sendPostJson(getAxiCancelLimitApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("getAxiCancelLimitApi:return " + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(null);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getAxiCancelLimitApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/getAxiDataInfoList")
    public Result getAxiDataInfoList(String search,String startTime,String endTime, Integer page, Integer pageSize) {
        String getAxiDataInfoListApi = getAxiApi + "/api/Axi/getAxiDataInfoList";
        try {
            String userId = UserHeaderHolder.getUserId();
            if(page == null){
                page = 1;
            }
            if(pageSize == null){
                pageSize = 10;
            }
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("startTime", startTime);
            params.put("endTime", endTime);
            params.put("search", search);
            params.put("page", page);
            params.put("pageSize", pageSize);
//            params.put("userId", userId);
            String res = HttpUtil.sendPostJson(getAxiDataInfoListApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("getAxiDataInfoList:return " + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                final JSONObject data = resObj.getJSONObject("Data");
                return ResultUtil.success(data);
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + getAxiDataInfoListApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/outputAllAxiInfo")
    public  Result outputAllAxiInfo(){
        String outputAllAxiInfoApi = getAxiApi + "/api/Axi/outputAllAxiDataInfoList";
        try {
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            String res = HttpUtil.sendPostJson(outputAllAxiInfoApi, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("outputAllAxiInfoApi:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(resObj.get("Data"));
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + outputAllAxiInfoApi);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/outputSelectAxiInfo")
    public  Result outputSelectAxiInfo(String ids){
        String outputSelectAxiInfo = getAxiApi + "/api/Axi/outputSelectAxiDataInfoList";
        try {
            String md5Sign = CommonUtils.encryptToMD5(CommonUtils.encryptToMD5(sign));
            JSONObject params = new JSONObject();
            params.put("sign", md5Sign);
            params.put("ids", ids);
            String res = HttpUtil.sendPostJson(outputSelectAxiInfo, params);
            System.out.println(CommonUtils.formatCurrentTime() + "==========================================");
            System.out.println("outputSelectAxiInfo:return" + res);
            JSONObject resObj = JSONObject.parseObject(res);
            if ("200".equals(resObj.get("Code").toString())) {
                return ResultUtil.success(resObj.get("Data"));
            }
            return ResultUtil.error(500, resObj.get("Msg").toString(), resObj.get("Msg").toString(), null);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("接口请求地址：" + outputSelectAxiInfo);
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/sfcTest")
    public  void sfcTest(){
        try {
            sfcScdpMSnDetailService.scheduledCalculateFirstPassRate();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
